package com.app.web.filters;

import com.app.service.impl.SelectorData;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import java.util.HashMap;
import java.util.Map;

/**
 * Copyright (C) @2020 fuguo.wang@logicsolutions.com.cn
 *
 * @author fuguo.wang
 * @version 1.0
 * @className AppListener
 * @date 2020-06-20 0:37
 * @description APP监听器
 */
@WebListener("系统监听器")
public class AppListener implements ServletContextListener {


	/**
	 * 系统启动  servlet 初始化的时候 调用该方法
	 *
	 * @param sce
	 */
	@Override
	public void contextInitialized(ServletContextEvent sce) {
		/**
		 * 获取 ServletContext 又称application作用域  四大作用域一种
		 */
		ServletContext application = sce.getServletContext();
		Map<String, String[]> datas = new HashMap<>();

		// 添加民族
		datas.put("NATIONS",SelectorData.getNationSelector());
		// 添加政治面貌
		datas.put("POLITICAL_STATUS",SelectorData.getPoliticalStatusSelector());
		// 添加婚姻状况
		datas.put("MARITAL_STATUS",SelectorData.getMaritalStatusSelector());
		// 获取文化程度
		datas.put("EDUCATION_LEVEL",SelectorData.getEducationLevelSelector());

		application.setAttribute("STATICDTATD", datas);
	}
}
